﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminMaster.master" Inherits="System.Web.Mvc.ViewPage<Eacademy.Domain.Models.MentorListViewModel>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $(".delete-mentor-link").live("click", function (event) {
                event.preventDefault();
                var $link = $(this);
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 120,
                    modal: true,
                    draggable: false,
                    buttons: {
                        "Continue": function () {
                            $(this).dialog("close");
                            $.post($link.attr("href"), null, reloadPage);
                        },
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            })
        });

        function reloadPage() { location.reload(true); }

    </script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3>Mentor List</h3>
    <input type="button" value="Add Mentor" onclick="window.open('/admin/mentors/add/','_self')" class="button-style"/>
    <br />
    <br />
    <%=Html.Grid(Model.MentorList).Columns(column =>
      {
          column.For(x => x.FirstName).Sortable(true);
          column.For(x => x.MiddleName).Sortable(true);
          column.For(x => x.LastName).Sortable(true);
          column.For(x => x.EmployeeNumber).Sortable(true);
          column.For(x => Html.ActionLink("Edit", "Edit", new { id = x.MentorId }));
          column.For(x => Html.ActionLink("Delete", "Delete", new { id = x.MentorId }, new { @class = "delete-mentor-link" }));          
      }).Sort(Model.GridSortOptions)
            .Attributes(@id => "grid-style" , cellspacing => "0",cellpadding => "0")
            .Empty("No mentors")%>
    <div class="event-paging">
        <div class="pager">
            <% if (Model.MentorList.TotalItemCount > Model.MentorList.PageSize)
               {%>
            <%= Html.Pager(Model.MentorList.PageSize, Model.MentorList.PageNumber, Model.MentorList.TotalItemCount)%>
            <%} %>
        </div>
    </div>
        <div id="dialog-confirm" title="Delete this mentor?" style="display: none;">
        <p>
            Are you sure you want to delete this mentor?</p>
    </div>
</asp:Content>
